package org.zpmis.domain.customer.vo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.zpmis.domain.customer.model.CustomerPlan;

import javax.persistence.*;
import java.io.Serializable;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CustomerPlanListVo {
    /**
     * 主键id
     */
    private Long id;

    /**
     * 意向表id
     */
    private Long intentionId;

    /**
     * 企业表id
     */
    private Long companyId;

    /**
     * 回访对象 1 意向客户  2 企业客户
     */
    private Integer visitObject;

    /**
     * 跟进人id
     */
    private Long chargePersonId;

    /**
     * 负责人、跟进人
     */
    private String chargePerson;

    /**
     * 回访表id
     */
    private Long visitId;

    /**
     * 企业名称
     */
    private String companyName;

    /**
     * 联系人
     */
    private String contactPerson;

    /**
     * 联系手机号
     */
    private String contactMobile;

    /**
     * 跟进计划描述
     */
    private String planDesc;

    /**
     * 回访方式
     */
    private Integer visitType;

    /**
     * 回访日期
     */
    private String visitTime;

    /**
     * 是否删除
     */
    private Integer isDeleted;

    /**
     * 回访状态 1进行中2已完结
     */
    private Integer status;

    /**
     * 是否提醒
     */
    private Integer isRemind;

    /**
     * 备注
     */
    private String remake;

    /**
     * 创建人id
     */
    private Long createId;

    /**
     * 创建人
     */
    private String createPerson;

    /**
     * 创建时间
     */
    private String createTime;

    /**
     * 企业code
     */
    private String companyCode;


    public CustomerPlanListVo(CustomerPlan customerPlan) {
        this.id = customerPlan.getId();
        this.intentionId = customerPlan.getIntentionId();
        this.companyId = customerPlan.getCompanyId();
        this.visitObject = customerPlan.getVisitObject();
        this.chargePersonId = customerPlan.getChargePersonId();
        this.chargePerson = customerPlan.getChargePerson();
        this.visitId = customerPlan.getVisitId();
        this.companyName = customerPlan.getCompanyName();
        this.contactPerson = customerPlan.getContactPerson();
        this.contactMobile = customerPlan.getContactMobile();
        this.planDesc = customerPlan.getPlanDesc();
        this.visitType = customerPlan.getVisitType();
        this.visitTime = customerPlan.getVisitTime() == null ? "" : LocalDateTime.ofInstant(Instant.ofEpochMilli(customerPlan.getVisitTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        this.isDeleted = customerPlan.getIsDeleted();
        this.status = customerPlan.getStatus();
        this.isRemind = customerPlan.getIsRemind();
        this.remake = customerPlan.getRemake();
        this.createId = customerPlan.getCreateId();
        this.createPerson = customerPlan.getCreatePerson();
        this.createTime = customerPlan.getCreateTime() == null ? "" : LocalDateTime.ofInstant(Instant.ofEpochMilli(customerPlan.getCreateTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));;
        this.companyCode = customerPlan.getCompanyCode();
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", intentionId=").append(intentionId);
        sb.append(", companyId=").append(companyId);
        sb.append(", visitObject=").append(visitObject);
        sb.append(", chargePersonId=").append(chargePersonId);
        sb.append(", chargePerson=").append(chargePerson);
        sb.append(", visitId=").append(visitId);
        sb.append(", companyName=").append(companyName);
        sb.append(", contactPerson=").append(contactPerson);
        sb.append(", contactMobile=").append(contactMobile);
        sb.append(", planDesc=").append(planDesc);
        sb.append(", visitType=").append(visitType);
        sb.append(", visitTime=").append(visitTime);
        sb.append(", isDeleted=").append(isDeleted);
        sb.append(", status=").append(status);
        sb.append(", isRemind=").append(isRemind);
        sb.append(", remake=").append(remake);
        sb.append(", createId=").append(createId);
        sb.append(", createPerson=").append(createPerson);
        sb.append(", createTime=").append(createTime);
        sb.append(", companyCode=").append(companyCode);
        sb.append("]");
        return sb.toString();
    }
}